Ccay.Module.define("Ccay.example.ui.igird.page",function(page,$S){
	page.ready = function() {
		
		var gridOption11 = {
			showPager: true,
			pagerOp:{
				pageInf: {
					pageSize: 8,
					curPage: 2
				},
				pageSizes:[8, 10, 15, 20, 50, 100, 200, 500]
			}, 
		    columns: [
		 		{field: 'name', width:90, header: "ccay.common.label.name"},
		 		{field: 'sex', width:70, header: "sSex", type: 'bool', format: {isIcon: true}},
		 		{field: 'age', width:70, header: "sAge", type: 'integer'},
		 		{field: 'birthday', width:110, header: "sBirthday", type: 'date'},
		 		{field: 'tuition', width: 170, header: "Tuition", type: 'rate', format: {htmlView: true, section: [20, 40, 80]}},
		 		{field: 'blog', width:200, header: "sBlog"},
		 		{field: 'lastUpdateDate', width:130, header: "ccay.common.label.lastUpdatedDate", type: 'datetime',content: "${#getLastTime(lastUpdateDate)}"}
		    ],
			ajax: {
			   	url: 'services/ccay/demo/student/list/page/${pageSize}/${curPage}/${orderBy}'
			}
		};
		
		var gridOption12 = {
			showPager: true,
			pagerOp:{
				mode:"pager",
				pageInf: {
					pageSize: 8,
					curPage: 2
				},
				pageSizes:[8, 10, 15, 20, 50, 100, 200, 500]
			}, 
		    columns: [
		 		{field: 'name', width:90, header: "ccay.common.label.name"},
		 		{field: 'sex', width:70, header: "sSex", type: 'bool', format: {isIcon: true}},
		 		{field: 'age', width:70, header: "sAge", type: 'integer'},
		 		{field: 'birthday', width:110, header: "sBirthday", type: 'date'},
		 		{field: 'tuition', width: 170, header: "Tuition", type: 'rate', format: {htmlView: true, section: [20, 40, 80]}},
		 		{field: 'blog', width:200, header: "sBlog"},
		 		{field: 'lastUpdateDate', width:130, header: "ccay.common.label.lastUpdatedDate", type: 'datetime', content: "${#getLastTime(lastUpdateDate)}"}
		    ],
			ajax: {
			   	url: 'services/ccay/demo/student/list/page/${pageSize}/${curPage}/${orderBy}'
			}
		};
		
		var gridOption2 = {
			height: 230,
			showPager: true,
			lazyLoad: true,
//			_scrollOp: {
//	   			start: 1,
//	   			end: 8,
//	   			pageSize: 8
//	   		},
			pagerOp:{
				pageInf: {
					pageSize: 8
				}
			},
	        columns: [
				 {field: 'id', width: 100, header: 'id'},
 			     {field: 'name', width:100, header: "name"},
 				 {field: 'description', width:200, header: "description"}
	        ],
		    ajax: {
		    	url: 'services/ccay/demo/grid/list/ranged/${start}/${end}/${orderBy}/${total}'
		    }
	    };
		
		$S("#pageDemo").ccayTab();
		
		$S("li[tabid='tab2']").one("click", function () {
			$S("#iStudent11").igrid(gridOption11);
		});
		
	    $S("li[tabid='tab2']").one("click", function () {
			$S("#iStudent12").igrid(gridOption12);
		});
		
		$S("li[tabid='tab3']").one("click", function () {
			$S("#iStudent2").igrid(gridOption2);
		});
	};
	
	getLastTime = function(data){
		return Ccay.Format.toDateBefore(data && data.getUTCTime());
	};
	
	page.openDemo = function(tabId){
		$S("#pageDemo").getCcayTabManager().selectItem(tabId);
		$S("li[tabid='" + tabId + "']").click();
	};
	
});